<template>
  <div>
    <div class="top">
      <van-nav-bar
        title="编辑地址"
        left-text=""
        left-arrow
        @click-left="onClickLeft"
      />
    </div>
    <div class="main">
      <van-address-edit
        :area-list="areaList"
        :columns-num="2"
        show-postal
        value="110101"
        show-delete
        show-set-default
        show-search-result
        :columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @delete="onDelete"
      />
    </div>
    <input type="text" v-model="dd" />
  </div>
</template>

<script>
import Vue from "vue";
import { Area } from "vant";
Vue.use(Area);
import {} from "../../request/api";
import { Toast } from "vant";
import { areaList } from "@vant/area-data";
import eventBus from "@/eventBus";
export default {
  data() {
    return {
      areaList,
      doarr: [],
      dd: "",
    };
  },
  created() {
    // $on作用就是监听实例上的自定义事件
    // eventBus.$on("你要监听的自定义事件名",(val这个形参就是你监听自定义事件上面的数据)=>{})
    eventBus.$on("xiaoming", (val) => {
      console.log(val);
      this.addressDetail = val.addressDetail;
      console.log("this地址" + val.addressDetail);
      console.log("val地址" + val.addressDetail);
      this.name = val.name;
      this.dd = val.name;
    });
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onSave(val) {
      console.log(val);
    },

    onDelete(val) {
      console.log(val);
    },
  },
};
</script>

<style>
</style>